package com.itheima.HOMEW;

public class MyRectangle {
   /* 请定义一个描述矩形（MyRectangle）的类，
    包含宽和高两个属性，提供获取矩形周长（perimeter）和面积（area）的方法。
    并编写测试类进行测试。*/
   int width;
   int height;
   public MyRectangle(){

   }
   public MyRectangle(int width,int height){
       this.height = height;
       this.width = width;
   }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getWidth() {
        return width;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getHeight() {
        return height;
    }
    public void perimeter(){
        System.out.println("周长为"+(height+width)*2);
    }
    public void area(){
        System.out.println("面积为"+height*width);
    }
}
class testRectangle{
    public static void main(String[] args) {
        MyRectangle p = new MyRectangle();
        p.setHeight(12);
        p.setWidth(12);
        p.perimeter();

        MyRectangle s = new MyRectangle(18,12);
        s.area();
    }

}
